<?php

class ModelToolSeoUrl extends Model {

   public function http($route) {
        return HTTP_SERVER . 'index.php?route=' . str_replace('&', '&amp;', $route);
    }

    public function https($route) {
        if (HTTPS_SERVER != '') {
            $link = HTTPS_SERVER . 'index.php?route=' . str_replace('&', '&amp;', $route);
        } else {
            $link = HTTP_SERVER . 'index.php?route=' . str_replace('&', '&amp;', $route);
        }
                
        return $link;
    }
    public function seo_link($link){
        if (HTTPS_SERVER != '') {
            $link = HTTPS_SERVER .$link.'/';
        } else {
            $link = HTTP_SERVER.$link.'/';
        }
                
        return $link;
    }
    public function khongdau($text){
        //global $ibforums;
        //Charachters must be in ASCII and certain ones aint allowed
        $text = html_entity_decode ($text, ENT_QUOTES, 'UTF-8');
        $text = preg_replace("/(ä|à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ)/", 'a', $text);
        $text = str_replace("ç","c",$text);
        $text = preg_replace("/(è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ)/", 'e', $text);
        $text = preg_replace("/(ì|í|î|ị|ỉ|ĩ)/", 'i', $text);
        $text = preg_replace("/(ö|ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ)/", 'o', $text);
        $text = preg_replace("/(ü|ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ)/", 'u', $text);
        $text = preg_replace("/(ỳ|ý|ỵ|ỷ|ỹ)/", 'y', $text);
        $text = preg_replace("/(đ)/", 'd', $text);
        //CHU HOA
        $text = preg_replace("/(Ä|À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ)/", 'A', $text);
        $text = str_replace("Ç","C",$text);
        $text = preg_replace("/(È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ)/", 'E', $text);
        $text = preg_replace("/(Ì|Í|Ị|Ỉ|Ĩ)/", 'I', $text);
        $text = preg_replace("/(Ö|Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ớ|Ợ|Ở|Ỡ)/", 'O', $text);
        $text = preg_replace("/(Ü|Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ)/", 'U', $text);
        $text = preg_replace("/(Ỳ|Ý|Ỵ|Ỷ|Ỹ)/", 'Y', $text);
        $text = preg_replace("/(Đ)/", 'D', $text);
        $text = preg_replace("/[^a-zA-Z0-9\-\_]/", ' ', $text);
        $text = str_replace("     ", ' ', $text);
        $text = str_replace("    ", ' ', $text);
        $text = str_replace("   ", ' ', $text);
        $text = str_replace("  ", ' ', $text);
        $text = str_replace(" ", '-', trim($text));
        $text = str_replace("---", '-', $text);
        return strtolower($text);
    }

}

?>